﻿Create proc proc_getDonViTinh
(
 @MaVatTu varchar(10)
)
as
SELECT [STT] 
	  ,[DonViTinh]
      ,[GiaTriQuiDoi]
      ,[LaMacDinh]
  FROM [QuanLyKho].[dbo].[DonViTinh]
  WHERE MaVatTu = @MaVatTu
go
  
create proc proc_getDanhSachKho
as
SELECT [MaKho]
      ,[TenKho]
      ,[Tên Kho] = dbo.func_ChuyenCoDauThanhKhongDau(TenKho)
  FROM [QuanLyKho].[dbo].[Kho]
go

Create proc proc_getDanhSachHangHoaTrongKho
(
 @MaKho varchar(10)
)
as
select TenVatTu = dbo.func_getTenVatTuFromMaVatTu(MaVatTu)
	  ,SoLuong = dbo.func_getSoLuongTonKho(MaVatTu)
	  ,[Tên vật tư] = dbo.func_ChuyenCoDauThanhKhongDau(dbo.func_getTenVatTuFromMaVatTu(MaVatTu))
  from [QuanLyKho].[dbo].HangHoaTrongKho
 where MaKho = @MaKho
go

create proc proc_getDanhSachHopDong
as
SELECT [MaHopDong]
	  ,[NgayLap]
      ,[DoiTac]
      ,[Đối tác] = dbo.func_ChuyenCoDauThanhKhongDau(DoiTac)
      ,[path]
  FROM [QuanLyKho].[dbo].[HopDong]
GO

Create proc proc_getDanhSachTienTe
as
SELECT [KyHieu]
      ,[LoaiTien]
      ,[TyGia]
  FROM [QuanLyKho].[dbo].[TienTe]
GO

Create proc proc_getDanhSachNhapKhau
as
SELECT [SoChungTu]
      ,[Ngay]
      ,[TenNhaCungCap]
      ,[MaHopDong]
      ,[LoaiTien]
      ,[DaXacNhan]
      ,[DaTraTien]
      ,[TongCong]
      ,[GhiChu]
  FROM [QuanLyKho].[dbo].[NhapKhau],NhaCungCap 
  where NhaCungCap.MaNhaCungCap = NhapKhau.MaNhaCungCap
GO